<template>
    <div>
        <el-tabs type="border-card">
            <el-tab-pane label="进货管理">
                <div class="cb_jintable">
                    <el-table
                        :data="tableData"
                        height="250"
                        border
                        :header-cell-style="{backgroundColor:'#409EFF',textAlign:'center',color:'white'}"
                        :cell-style="{textAlign:'center'}"
                        style="width: 100%">
                    <el-table-column
                            prop="id"
                            label="消耗品编码"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="goodsName"
                            label="消耗品名称"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="goodsClassifyName"
                            label="消耗品类型"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="unit"
                            label="消耗品价格"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="number"
                            label="消耗品数量"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="provider"
                            label="供应商">
                    </el-table-column>
                </el-table>
                </div>
                <div class="cb_btn">
                    <el-button type="primary"  @click="tianjia">添加消耗品</el-button>
                    <el-button type="primary"  @click="jinhuo">确认进货</el-button>
                </div>
                <div class="cb_tankuang" >
                    <el-dialog title="消耗品信息" :visible.sync="dialogFormVisible" width="25%"
                               center>
                        <el-form :model="form" size="mini">
                            <el-form-item label="消耗品编码:" :label-width="formLabelWidth">
                                <el-input v-model="form.id" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="消耗品名称:" :label-width="formLabelWidth">
                                <el-input v-model="form.goodsName" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="消耗品类型:" :label-width="formLabelWidth">
                                <el-input v-model="form.goodsClassifyName" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="消耗品价格:" :label-width="formLabelWidth">
                                <el-input v-model="form.unit" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="消耗品数量:" :label-width="formLabelWidth">
                                <el-input v-model="form.number" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="消耗品供应商:" :label-width="formLabelWidth">
                                <el-input v-model="form.provider" autocomplete="off"></el-input>
                            </el-form-item>
                        </el-form>
                        <div slot="footer" class="dialog-footer">
                            <el-button type="primary" @click="queding">提 交</el-button>
                            <el-button @click="dialogFormVisible = false">取 消</el-button>
                        </div>
                    </el-dialog>
                </div>

            </el-tab-pane>
            <el-tab-pane label="出货管理">
                <Chuhuo></Chuhuo>
            </el-tab-pane>
        </el-tabs>

    </div>
</template>

<script>
    import {mapActions, mapState} from 'vuex'
    import axios from 'axios'/*'../../http/http'*/
    /*import * as api from '../../http/api'*/
    import Chuhuo from "./cb_chuhuo"
    export default {
        components:{
            Chuhuo,
        },
            data() {
                return {
                    tableData:[],
                    dialogTableVisible: false,
                    dialogFormVisible: false,
                    form: {
                        id: '',
                        goodsName: '',
                        goodsClassifyName: '',
                        unit: '',
                        number:'',
                        provider:'',
                    },
                    formLabelWidth: '100px',
                }
            },
            methods: {
                tianjia() {
                    this.dialogFormVisible = true
                },
                queding(){
                    let Data={
                        "id": this.form.id,
                        "goodsName": this.form.goodsName,
                        "goodsClassifyName": this.form.goodsClassifyName,
                        "number": this.form.number,
                        "unit": this.form.unit,
                        "provider": this.form.provider,
                    }
                    this.tableData.push(Data);
                    this.dialogFormVisible= false;
                    this.$message({
                        type: 'success',
                        message: '添加消耗品成功!'
                    })
                },
                ...mapActions(['jinh']),
                jinhuo(){
                    for ( let i = 0; i < this.tableData.length; i++) {
                        let data={
                            "id":this.tableData[i].id,
                            "number": this.tableData[i].number,
                            "unit": this.tableData[i].unit,
                        }
                        this.jinh(data)
                    }
                    this.$message({
                        type: 'success',
                        message: '进货成功!'
                    })
                }
        }

    }
</script>

<style scoped>

</style>